<template>
	<view class="content">
		<view class="Nav" style="display: flex;align-items: center;background: transparent;opacity: 1;padding: 113rpx 30rpx 35rpx 30rpx;position: fixed;top: 0;
			left: 0;width: 100%;">
			<u-icon name="arrow-left" size="40rpx" color="#fff" @click="Goback"></u-icon>
			<view style="font-weight: bold;font-size: 36rpx;color: #FFFFFF;margin-left: 244rpx;">
				我的积分
			</view>
			<view style="font-size: 32rpx;color: #FFFFFF;flex:1;text-align: right;"
				@click="navigateToHandle('/pages/member/integral/index')">
				积分明细
			</view>
		</view>
		<view style="height:193rpx ;">

		</view>
		<view class="IconIcon" style="display: flex;align-items: center;flex-direction: column;">
			<image src="/static/jf.png" style="width: 280rpx;height: 280rpx;margin-top: 114rpx;" mode=""></image>
			<view style="margin: 30rpx 0 20rpx 0;font-size: 32rpx;color: #fff; ">
				积分总额
			</view>
			<view style="font-size: 80rpx;font-weight: bold;color: #fff;margin-bottom: 96rpx;">
				{{data.length ? data[0].balance : 0}}
			</view>
			<!-- <view class="dh" @click="Toshow">
				兑换
			</view> -->
			<u-popup round='30rpx' bgColor='transparent' :closeable="true" :show="show" title="兑换积分" @close="close"
				:closeOnClickOverlay='false' mode="center">
				<view class="ShowBox">
					<view class="Title">
						兑换积分
					</view>
					<view class="InputBox">
						<u-input type="number" maxlength="7" customStyle='font-weight: bold;' color="#F2D7AAFF"
							fontSize='72rpx' inputAlign='center' v-model="dhmoney" border="none"></u-input>
						<view class="Line" style="height: 2rpx;background-color: #EDEBF9FF;">
						</view>
					</view>
					<view class="Tips">
						兑换<text>{{dhmoney?dhmoney:0}}</text>积分，需要扣除余额<text>{{money}}</text>元
					</view>
					<view class="OK" @click="OKdh2">
						确认兑换
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				dhmoney: '',
				show: false,
				bl: this.$store.state.config.point_balance
			}
		},
		onLoad() {
			this.getlist()
		},
		computed: {
			money() {
				let data = this.dhmoney / this.bl
				return data.toFixed(2)
			}
		},
		methods: {
			Subdh() {
				this.show = false
			},
			close() {
				this.show = false
			},
			OKdh2() {
				this.show = false
				let that = this
				uni.showModal({
					content: '确认兑换？',
					success: (res) => {
						if (res.confirm) {
							that.OKdh()
						}
					}
				})
			},
			OKdh() {
				this.$api.Pointdh({
					money: this.dhmoney
				}, res => {
					if (res.status) {
						this.show = false
						uni.showToast({
							title: '兑换成功',
							duration: 2500,
							icon: 'none',
							success: () => {
								setTimeout(() => {
									uni.navigateTo({
										url: '/pages/member/index/index'
									})
								}, 1000)
							}

						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			Toshow() {
				this.show = true
			},
			Goback() {
				uni.navigateBack()
			},
			getlist() {
				let _this = this
				_this.$api.pointLog({}, res => {
					this.data = res.data
				})
			},
			navigateToHandle(e) {
				uni.navigateTo({
					url: e
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	.dh {
		padding: 20rpx 220rpx;
		border-radius: 20rpx;
		background: linear-gradient(180deg, #F2D7AA 0%, #DEBC86 100%);
		box-shadow: 0rpx 10rpx 40rpx rgba(0, 0, 0, 0.53);

	}

	.ShowBox {
		width: 635rpx;
		height: 607rpx;
		border-radius: 30rpx;
		background: #181818;

		.Title {
			text-align: center;
			padding-top: 27rpx;
			padding-bottom: 37rpx;
			color: #fff;
			border-bottom: 1px solid #b9b9b920;
		}

		.InputBox {
			padding: 82rpx 30rpx 0;

			.Line {
				margin-top: 51rpx;
			}

			margin-bottom: 19rpx;
		}

		.Tips {
			text-align: center;
			color: #fff;

			text {
				color: #F2D7AAFF;
			}
		}

		.OK {
			margin: 0 40rpx;
			padding: 21rpx 0;
			text-align: center;
			margin-top: 88rpx;
			background: linear-gradient(180deg, #F2D7AA 0%, #DEBC86 100%);
			border-radius: 10rpx;
		}
	}
</style>